package com.example.demo1.Service;

import com.example.demo1.Bean.UserBean;
import com.example.demo1.Mapper.UserMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.time.LocalDate;
import java.util.List;

@Service
public class UserServiceImpl implements UserService {

    @Resource
    UserMapper UserMapper;

    @Override
    public PageInfo<UserBean> selectUserBykw(int pageNum, int pageSize,String keyword,String LastDateArrorder) {
        PageHelper.startPage(pageNum, pageSize);
        List<UserBean> allOrderPresentList = UserMapper.selectUserBykw(keyword,LastDateArrorder);
        PageInfo<UserBean> pageInfo = new PageInfo<>(allOrderPresentList);
        return pageInfo;
    }
    @Override
    public PageInfo<UserBean> selectAllUser(int pageNum, int pageSize,String LastDateArrorder){
        PageHelper.startPage(pageNum, pageSize);
        List<UserBean> allOrderPresentList = UserMapper.selectAllUser(LastDateArrorder);
        PageInfo<UserBean> pageInfo = new PageInfo<>(allOrderPresentList);
        return pageInfo;
    }
    @Override
    public void deleteUser(String UserId){
        UserMapper.deleteUser(UserId);
    }

    @Override
    public void updateUser(String isLogin,String UserId,String UserName,String UserSex,String UserPhone,String UserAddress) {
        UserMapper.updateUser(isLogin,UserId,UserName,UserSex,UserPhone,UserAddress);
    }

    @Override
    public List<UserBean> getAllUser(){
        return UserMapper.getAllUser();
    }

    @Override
    public UserBean getUserByname(String name){
        return  UserMapper.getUserByname(name);
    }

    @Override
    public void updateUserLastDate(String UserId, LocalDate date){
        UserMapper.updateUserLastDate(UserId,date);
    }

    @Override
    public void insertUser(String userid,String username,String usersex,String userphone,String usearddress,LocalDate date){
        UserMapper.insertUser(userid,username,usersex,userphone,usearddress,date);
    }

}
